const GIT_CURRENT_BRANCH_COMMAND = 'git rev-parse --abbrev-ref HEAD'
const GIT_BRANCH_LIST_COMMAND = 'git branch'
const GIT_LOG_FIFTY_COUNT = 'git log -50 --date=iso --pretty=format:\'{"commit": "%h","author": "%aN <%aE>","date": "%ad","message": "%s"},\' $@ | perl -pe \'BEGIN{print "["}; END{print "]\n"}\' | perl -pe \'s/},]/}]/\''

const GIT_EXIST = 'git rev-parse --is-inside-work-tree'

const GIT_STATUS_PORCELAIN = 'git status --porcelain'

function getDiffCommand(branchOrCommit) {
  return `git diff ${branchOrCommit || 'master'} --cached --diff-filter=ACMR --name-only`
}

exports.GIT_CURRENT_BRANCH_COMMAND = GIT_CURRENT_BRANCH_COMMAND
exports.GIT_BRANCH_LIST_COMMAND = GIT_BRANCH_LIST_COMMAND
exports.GIT_LOG_FIFTY_COUNT = GIT_LOG_FIFTY_COUNT
exports.GIT_EXIST = GIT_EXIST
exports.GIT_STATUS_PORCELAIN = GIT_STATUS_PORCELAIN
exports.getDiffCommand = getDiffCommand

module.exports = {
  GIT_CURRENT_BRANCH_COMMAND,
  GIT_BRANCH_LIST_COMMAND,
  GIT_LOG_FIFTY_COUNT,
  GIT_EXIST,
  GIT_STATUS_PORCELAIN,
  getDiffCommand
}